<?php

namespace api\controller;

// +----------------------------------------------------------------------
// | 基础模块（任务）数据控制层
// +----------------------------------------------------------------------

use common\controller\VerifyController;
use common\exception\LogicException;
use common\service\TodoService;
use think\Request;

class TodoController extends VerifyController
{

    /** @var TodoService */
    private $todoService;


    public function __construct()
    {
        parent::__construct();
        $this->todoService = TodoService::getInstance();
    }

    /**
     * 待办任务列表
     * @param Request $request
     * @return \think\Response|void
     * @throws \think\Exception
     */
    public function taskList(Request $request)
    {
        $param = $request->param()['param'];
        $filter = $param['filter'] ?? [];
        $page = $param['page'] ?? [1, C("database.database_max_select_rows")];
        try {
            $resData = $this->todoService->taskList($param, $filter, $page, $request->getUserId(), $request->getTenantId());
            return json(success_response('', $resData));
        } catch (LogicException $e) {
            throw_strack_exception($e->getMessage(), $e->getCode());
        }
    }

}
